//
//  DefaultSettingVC.m
//  SelfDriving
//
//  Created by apple on 16/8/1.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "DefaultSettingVC.h"
#import "BusinessService+User.h"
@interface DefaultSettingVC ()
@property (weak, nonatomic) IBOutlet UISwitch *sw1;
@property (weak, nonatomic) IBOutlet UISwitch *sw2;

@end

@implementation DefaultSettingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self ref];
}
-(void)ref{
    [[AppDelegate shareDelegate]refdata:^(id res) {
        _sw1.on = [[AppDelegate shareDelegate].user.kuaipai_sendnearbyperson intValue]==0?NO:YES;
        _sw2.on = [[AppDelegate shareDelegate].user.kuaipai_videoshow intValue]==0?NO:YES;
    }];
}
- (IBAction)sw1Action:(id)sender {
    UISwitch *sw = (UISwitch *)sender;
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:sw.on?@"1":@"0"  forKey:@"kuaipai_sendnearbyperson"];
     [[BusinessService shareInstance]setUserOtherConfig:dic success:^(id result) {
         [SVProgressHUD showImage:nil status:@"设置成功"];
         [self ref];
    } failure:^(id result) {
        [SVProgressHUD showErrorWithStatus:result];
    }];
}
- (IBAction)sw2Action:(id)sender {
    UISwitch *sw = (UISwitch *)sender;
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:sw.on?@"1":@"0"  forKey:@"kuaipai_videoshow"];
    [[BusinessService shareInstance]setUserOtherConfig:dic success:^(id result) {
        [SVProgressHUD showImage:nil status:@"设置成功"];
        [self ref];
    } failure:^(id result) {
        [SVProgressHUD showErrorWithStatus:result];
    }];
}

- (IBAction)backAction:(UIBarButtonItem *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}



@end
